package com.ruoyi.topInsectImg.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.topInsectImg.domain.*;
import com.ruoyi.topInsectImg.service.SendFrontService;
import com.ruoyi.topInsectImg.utils.HttpClientUtils;
import com.ruoyi.topInsectImg.utils.TopInsect;
import com.ruoyi.topInsectImg.utils.soa.SOAResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.IOException;
import java.util.*;

/**
 * 发送给前端的图片
 *
 * @author Mr-Le
 */
@Api("获取虫情测报灯图片")
@Slf4j
@RestController
@RequestMapping("/sendfront")
public class SendFrontController extends BaseController {

    /**
     * 存储文件的路径
     */
    @Value("${ruoyi.profile}")
    private String profile;

    @Autowired
    private SendFrontService sendFrontService;

    /**
     * 查询出所有结果
     * @param webFrontEnd
     * @return
     */
    @ApiOperation("查询已下载的insect图片列表,根据时间查找的时候，加上beginTime和end参数示例如下：" +
            "http://localhost:8080/sendfront/getimage?params%5BbeginTime%5D=2021-04-07&params%5BendTime%5D=2021-04-07")
    @GetMapping("/getimage")
    public TableDataInfo sendFront(WebFrontEnd webFrontEnd) {
        startPage();
        List<WebFrontEnd> webFrontEnds = sendFrontService.selectWebFrontEndList(webFrontEnd);
        return getDataTable(webFrontEnds);
    }

}
